"""
The LeakyReLUActivation class implements the Leaky ReLU activation function.
"""
import numpy as np

class LeakyReLUActivation:

    def __init__(self, alpha=0.01):
        """
        alpha: slope used for non-positive inputs (default 0.01).
        """
        self.alpha = alpha

    def forward_pass(self, batch_values):
        """
        Compute the Leaky ReLU activation for the input values.
        Leaky ReLU: f(x) = x if x > 0 else alpha * x
        """
        self.inputs = batch_values
        return np.where(batch_values > 0, batch_values, self.alpha * batch_values)

    def backward_pass(self, dvalues):
        """
        Compute the gradient of the loss with respect to the input values.
        Derivative of Leaky ReLU is 1 for positive values and alpha otherwise.
        """
        self.dvalues = dvalues * np.where(self.inputs > 0, 1.0, self.alpha)
        return self.dvalues
